package com.etv.launcher.common.utils;

import android.content.res.Resources;
import android.util.TypedValue;

public class UnitUtil {
    /**
     * dp转px
     * @param dp
     * @return
     */
    public static int dpToPx(Resources resource, float dp) {
        return (int) TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP,
                dp,
                resource.getDisplayMetrics()
        );
    }

    public static int dpToPx(Resources resource, double dp) {
        return dpToPx(resource,(float) dp);
    }
}
